package com.itheima.SingleInstanc2;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class JD implements Switch {
    private String name;
    private boolean flag;
    @Override
    public void press() {
        if (flag) {
            System.out.println(name + "按下了开关");
            flag = false;
        } else {
            System.out.println(name + "按下了关机");
            flag = true;
        }
    }

    public String getFlag() {
        return flag ? "开" : "关";
    }
}
